using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace DataHelper.BLL
{
    public class TK_Country
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public bool IsDeleted { get; set; }

        #region TK_CountrySelectAll
        public static List<TK_Country> TK_CountrySelectAll(string strSearch="",int top = 1, int bottom = 20, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.TK_Country.TK_CountrySelectAll(strSearch,top,bottom,ConnectionString);
            List<TK_Country> TK_CountryList = new List<TK_Country>();
            while(dr.Read())
            {
                TK_Country myTK_Country = new TK_Country
                {
                    ID = !dr.IsDBNull(dr.GetOrdinal("ID")) ? (int)dr["ID"] : 0,
                    Name = !dr.IsDBNull(dr.GetOrdinal("Name")) ? (string)dr["Name"] : null,
                    IsDeleted = !dr.IsDBNull(dr.GetOrdinal("IsDeleted")) ? (bool)dr["IsDeleted"] : false
                };
                TK_CountryList.Add(myTK_Country);
        }
        dr.Close();
        dr.Dispose();
        return TK_CountryList;
        }
        #endregion
        #region TK_CountrySelectRow
        public static TK_Country TK_CountrySelectRow(int ID, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.TK_Country.TK_CountrySelectRow(ID, ConnectionString);
            TK_Country tk_country = null;

            if(dr.Read())
            {
                tk_country= new TK_Country
                {
                    ID = !dr.IsDBNull(dr.GetOrdinal("ID")) ? (int)dr["ID"] : 0,
                    Name = !dr.IsDBNull(dr.GetOrdinal("Name")) ? (string)dr["Name"] : null,
                    IsDeleted = !dr.IsDBNull(dr.GetOrdinal("IsDeleted")) ? (bool)dr["IsDeleted"] : false,

                };
            }
        dr.Close();
        dr.Dispose();
        return tk_country;
        }
        #endregion
        #region TK_CountryInsertRow
        public static void TK_CountryInsertRow(int ID, string Name, bool IsDeleted, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.TK_Country.TK_CountryInsertRow(ID, Name, IsDeleted, ConnectionString);
        }
        #endregion
        #region TK_CountryUpdateRow
        public static void TK_CountryUpdateRow(int ID, string Name, bool IsDeleted, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.TK_Country.TK_CountryUpdateRow(ID, Name, IsDeleted, ConnectionString);
        }
        #endregion
        #region TK_CountryDeleteRow
        public static void TK_CountryDeleteRow(int ID, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.TK_Country.TK_CountryDeleteRow(ID,ConnectionString);
        }
        #endregion
    }
}
